package com.bjsxt.generic;

/**
 * 泛型方法
 */
public class Collections1 {
    /**
     * 泛型方法
     */
    public static <T> void addAll(List1<T> col, T... t){

    }
    /**
     * 泛型方法
     */
    public static <T> void method1(List1<T> list){ //泛型实参可以是任意类型

    }
    //不是泛型方法
    public static void method2(List1<Person> list){ //泛型实参只能是Student

    }
    //不是泛型方法
    public static void method3(List1<? super Person> list){ //泛型实参可以是Person及其上级类  下限

    }
    //不是泛型方法
    public static void method4(List1<? extends Person> list){ //泛型实参可以是Person及其下级类 上限

    }

    public static void method5(List1<?> list){ // 实参，任意类型 不需要再方法上定义泛型

    }


    public static void main(String[] args) {
        List1<String> list = new ArrayList1();
        Collections1.addAll(list,"bjsxt","shsxt","wusxt");

        method1(new ArrayList1<Object>());
        method1(new ArrayList1<Person>());
        method1(new ArrayList1<Teacher>());
        method1(new ArrayList1<MiddleTeacher>());

        //method2(new ArrayList1<Object>());
        method2(new ArrayList1<Person>());
        //method2(new ArrayList1<Teacher>());
        //method2(new ArrayList1<MiddleTeacher>());

        method3(new ArrayList1<Object>());
        method3(new ArrayList1<Person>());
        //method3(new ArrayList1<Teacher>());
        //method3(new ArrayList1<MiddleTeacher>());

        //method4(new ArrayList1<Object>());
        method4(new ArrayList1<Person>());
        method4(new ArrayList1<Teacher>());
        method4(new ArrayList1<MiddleTeacher>());

        method5(new ArrayList1<Object>());
        method5(new ArrayList1<Person>());
        method5(new ArrayList1<Teacher>());
        method5(new ArrayList1<MiddleTeacher>());


    }




}

class Person{ }
class Teacher extends Person{  }
class MiddleTeacher extends Teacher{}
